package com.lzw.tool;

import java.util.*;
import java.util.concurrent.TimeUnit;

import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.exceptions.JWTCreationException;
import com.auth0.jwt.JWT;

class MainTest {
    public static void main(String[] args) {

        Map map = new HashMap<>();
        map.put("ll",null);
        map.put("lla",null);
        System.out.println(map);
        Integer AppId = 1500009959;
        String FileId = "387702294900248940";
        final long l = System.currentTimeMillis();
        Long.toHexString(l);
        final long CurrentTime = TimeUnit.MILLISECONDS.toSeconds(l);
        final long PsignExpire = CurrentTime + 13000L;
        String UrlTimeExpire = Long.toHexString(PsignExpire);
//        Integer CurrentTime = 1642557673;
//        Integer PsignExpire = 1742557673;
//        String UrlTimeExpire = "67dd51e9";

        String Key = "ENjwwMPk5LGltpXid7eg";
        HashMap<String, String> urlAccessInfo = new HashMap<String, String>();
        urlAccessInfo.put("t", UrlTimeExpire);

        try {
            Algorithm algorithm = Algorithm.HMAC256(Key);
            String token = JWT.create().withClaim("appId", AppId).withClaim("fileId", FileId)
                    .withClaim("currentTimeStamp", CurrentTime).withClaim("expireTimeStamp", PsignExpire)
//                    .withClaim("pcfg","basicDrmPreset")
                    .withClaim("urlAccessInfo", urlAccessInfo).sign(algorithm);
            System.out.println("token:" + token);
        } catch (JWTCreationException exception) {
            // Invalid Signing configuration / Couldn't convert Claims.
        }
    }
}
